package com.itheima.service.impl;

import com.itheima.mapper.UserMapper;
import com.itheima.pojo.User;
import com.itheima.service.UserService;
import com.itheima.utils.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public List<User> findByClassId() {
        return userMapper.findByClassId();
    }

    @Override
    public boolean addIntegral(Integer id, Integer integral) {
        return userMapper.addIntegral(id,integral)>0;
    }

    @Override
    public ResponseResult resetGScoreByGroupId(Long classId) {

        if(userMapper.resetGScoreByGroupId(classId)>0){
            return new ResponseResult(0,"操作成功","重置成功");
        }

        return new ResponseResult(1,"操作失败","重置失败");
    }
}
